package org.baseflexcharts.databoard
{
	import flash.display.Shape;
	
	import org.baseflexcharts.datapoints.RoundPoint;
	
	public class YOnlyPointLineDataBoard extends BaseDataBoard
	{
		public function YOnlyPointLineDataBoard()
		{
			super();
		}
		
		public override function draw():void
		{
			this.removeAllChildren();
				
			if (xAmount > 0 && yAmount > 0)
			{
				var unitWidth:uint = (this.width - leftMargin - rightMargin) / (xAmount - 1);
				var unitHeight:uint = (this.height - topMargin - bottomMargin) / (yAmount - 1);
				var remainHeight:uint = (this.height - topMargin - bottomMargin) % (yAmount - 1);
				
				var shape:Shape = new Shape();
				shape.graphics.lineStyle(lineWeight, lineColor, lineAlpha);

				if (dataProvider != null) {
				
					for (var i:uint = 0; i < dataProvider.length; i++)
					{
						var value:uint = uint(dataProvider.getItemAt(i).value);

						var tempX:uint = leftMargin + i * unitWidth;
						var tempY:uint = topMargin + remainHeight + unitHeight * (yAmount - 1 - value / yUnitValue);
					    
					    if (i == 0) {
					    	shape.graphics.moveTo(tempX, tempY);
					    } else {
					    	shape.graphics.lineTo(tempX, tempY);
					    }
					    
					    var point:RoundPoint = new RoundPoint(dataProvider.getItemAt(i).tip, 5, lineColor, 0xffffff, lineWeight, lineAlpha);
					    
					    point.x = tempX;
					    point.y = tempY;
					    
					    this.addChildAt(point, 0);
					}					
				}
				
				this.rawChildren.addChildAt(shape, 0);
			}
		}
	}
}